package com.googlecode.curvedmetromaps.core.model;

import org.jbox2d.common.Vec2;

import com.googlecode.curvedmetromaps.core.geometry.QuadraticBezier;

public class MetroEdge extends QuadraticBezier {
	public int			id;
	public MetroStation	src;
	public MetroStation	dst;
	// Control point for the Bézier curve.
	public float		cpX, cpY;

	public MetroEdge(MetroStation src, MetroStation dst) {
		this.src = src;
		this.dst = dst;
		cpX = (this.src.x + this.dst.x) / 2;
		cpY = (this.src.y + this.dst.y) / 2;
	}

	public MetroEdge(int id, MetroStation src, MetroStation dst, float cpX, float cpY) {
		this.id = id;
		this.src = src;
		this.dst = dst;
		this.cpX = cpX;
		this.cpY = cpY;
	}

	MetroStation getM1() {
		return src;
	}

	MetroStation getM2() {
		return dst;
	}

	@Override
	public Vec2 getP0() {
		return new Vec2(src.x, src.y);
	}

	@Override
	public Vec2 getP1() {
		return new Vec2(dst.x, dst.y);
	}

	@Override
	public Vec2 getCP() {
		return new Vec2(cpX, cpY);
	}

	public Vec2[] toArray() {
		Vec2[] result = { new Vec2(src.x, src.y), new Vec2(cpX, cpY), new Vec2(dst.x, dst.y) };
		return result;
	}
}
